<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<!DOCTYPE html>
<html>
	<head>
		<title>编辑签到</title>
		<meta name="decorator" content="default"/>
		<script type="text/javascript">
			$(function() {
				//初始化表单验证
				$("#inputForm").initValidform();
				
				$('#courseorderId').blur(function(){
					$("#inputForm").submit();
				})
				
				function showLocale(objD)
				{
					var str,colorhead,colorfoot;
					var yy = objD.getYear();
					if(yy<1900) yy = yy+1900;
					var MM = objD.getMonth()+1;
					if(MM<10) MM = '0' + MM;
					var dd = objD.getDate();
					if(dd<10) dd = '0' + dd;
					var hh = objD.getHours();
					if(hh<10) hh = '0' + hh;
					var mm = objD.getMinutes();
					if(mm<10) mm = '0' + mm;
					var ss = objD.getSeconds();
					if(ss<10) ss = '0' + ss;
					var ww = objD.getDay();
					if  ( ww==0 )  colorhead="<font color=\"#FF0000\">";
					if  ( ww > 0 && ww < 6 )  colorhead="<font color=\"#373737\">";
					if  ( ww==6 )  colorhead="<font color=\"#008000\">";
					if  (ww==0)  ww="星期日";
					if  (ww==1)  ww="星期一";
					if  (ww==2)  ww="星期二";
					if  (ww==3)  ww="星期三";
					if  (ww==4)  ww="星期四";
					if  (ww==5)  ww="星期五";
					if  (ww==6)  ww="星期六";
					colorfoot="</font>"
					str = colorhead + yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss + "  " + ww + colorfoot;
					return(str);
				}
				
				function tick()
				{
					today.setTime(today.getTime()+1000);
					$('.date-now').html(showLocale(today));
					window.setTimeout(tick, 1000);
				}
				
				var today = new Date(parseInt('${dateNow}'));
				
				tick();
			});
		</script> 
	</head>
	
	<body class="mainbody">
		<form:form id="inputForm" modelAttribute="siginin" action="${ctx}/qd/siginin/save" method="post" class="form-horizontal">
			<form:hidden path="id"/>
			<!--导航栏-->
			<div class="location">
				<a href="${ctx}/qd/siginin/list" class="back"><i></i><span>返回列表页</span></a>
				<a href="${ctx}/center" class="home"><i></i><span>首页</span></a> 
				<i class="arrow"></i> 
				<a href="${ctx}/qd/siginin/form?id=${siginin.id}"><span>签到</span></a>
				<shiro:hasPermission name="qd:siginin:edit"><i class="arrow"></i><span>${not empty siginin.id ? '修改':'添加' }签到</span></shiro:hasPermission>
			</div>	
			<div class="line10"></div>
			<!--/导航栏-->
	
			<div class="sigin-head">
				<h1><span class="date-now"></span></h1> 
				<form:input id="courseorderId" placeholder="请用扫描枪扫描学员App上的二维码" path="courseorderId" htmlEscape="false" maxlength="50" class="required" cssClass="input normal" datatype="*" nullmsg="请输入预约课程编号" errormsg="请输入预约课程编号" sucmsg=" "/>
			</div>
			<div class="sigin-body">
				<div class="sigin-left">
					<div class="sigin-info">
						<p><span class="sigin-status <c:if test="${not empty siginin and not empty siginin.student }">success</c:if>"> <c:choose><c:when test="${ not empty message }">${message }</c:when><c:otherwise>请用扫描枪扫描学员App上的二维码</c:otherwise></c:choose> </span></p>
						<c:if test="${not empty siginin and not empty siginin.student}">
						<p><span>学员：</span>${siginin.student.name }</p>
						<p><span>家长：</span>${siginin.member.name }</p>
						<p><span>预约课程：</span>${siginin.course.serial }${siginin.course.clevel } ${siginin.course.section }</p>
						<p><span>签到时间：</span><fmt:formatDate value="${siginin.signtime }" pattern="HH:mm"/></p>
						</c:if>
					</div>
				</div>
				<div class="sigin-right">
					<table class="table_notborder" style="font-size: 12px; width:100%;text-align: center">
			            <thead>
			                <tr>
			                	<th>预约号</th>
			                    <th>学员</th>
			                    <th>家长</th>
			                    <th>联系电话</th>
			                    <th>处理时间</th>
			                    <th>状态</th>
			                    <th>操作</th>
			                </tr>
			            </thead>
			            <tbody>
			            	<c:forEach items="${sigininList }" var="siginin">
			            	<tr>
			            		<td>${siginin.courseOrder.id}</td>
			                    <td>${siginin.student.name }</td>
			                    <td>${siginin.member.name }</td>
			                    <td>${siginin.member.mobile }</td>
			                    <td> <fmt:formatDate value="${siginin.signtime }" pattern="HH:mm"/> </td>
			                    <td class="status-color"> <c:choose><c:when test="${siginin.courseOrder.state=='signed' }">已到</c:when><c:when test="${siginin.courseOrder.state=='absented' }">旷课</c:when><c:when test="${siginin.courseOrder.state=='leaved' }">请假</c:when><c:when test="${siginin.courseOrder.state=='aborted' }">中止</c:when><c:otherwise>未到</c:otherwise> </c:choose></td>
			                    <td ><a href="${ctx}/qd/siginin/absent?id=${siginin.id}&courseid=${siginin.course.id}&mobile=${siginin.member.mobile }&studentname=${siginin.student.name}">旷课处理</a></td>
			                </tr>
			            	</c:forEach>
			            </tbody>
			        </table>
				</div>
				<div class="clear"></div>
			</div>
			<div class="sigin-bottom">
				<table class="table_notborder" style="font-size: 12px; width:100%;">
		            <tbody>
		            	<c:forEach items="${sections}" var="section">
		            	<tr>
		                    <td style="width:10%; text-align: center;">${section.name}</td>
		                    <td>
		                    	<c:forEach items="${section.courses }" var="course">
		                    	<c:if test="${not empty course and not empty course.serial}">
		                    	<div class="course <c:if test="${course.id==sigininCourseId}">selected</c:if>">
		                    		<a href="${ctx}/qd/siginin/form?courseId=${course.id}">
			                    		<span class="course-left">
			                    			<strong>${course.serial }</strong>
			                    			<strong>${course.clevel }</strong>
			                    		</span>
			                    		<span class="course-middle">
			                    			<strong>${course.classroom }</strong>
			                    			<strong>${course.sigins }/${course.orders }</strong>
			                    		</span>
			                    		<span class="course-right">
			                    			<strong></strong>
			                    		</span>
		                    		</a>
		                    	</div>	
		                    	</c:if>
		                    	</c:forEach>
		                    </td>
		                </tr>
		            	</c:forEach>
		            </tbody>
		        </table>
			</div>
			<!--/内容-->
		</form:form>
	</body>
</html>

